<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h2>我是标题</h2>
    <ul>
      <li>西瓜</li>
      <li>哈密瓜</li>
      <li>123</li>
      <li>2</li>
    </ul>
    <script>
      document.querySelectorAll('li').forEach((v) => {
        v.onclick = function () {
          console.log(this.innerHTML)
        }
      })
      console.log('123')
      console.log('456')
    </script>
  </body>
</html>
